@extends('layouts.accountmanage')

@section('title', '找回密码')

@section('header')
	@include('layouts.header-three')
@endsection

@section('content')
	<div class="wrapper-box">
		<div class="container">
			<div class="telRevise">
				<h2>找回密码</h2>
				<div class="telRevise-process telRevise-process1">
					<ul>
						<li class="indent10 processActive">验证身份</li>
						<li class="indent30 processActive">设置新密码</li>
						<li class="indent50">完成</li>
					</ul>
				</div>
				<div class="telRevise-form">
					<form class="form-horizontal" action="{{ route('postVerifyMobile') }}" method="post">
						{{ csrf_field() }}
						<div class="form-group">
							<label class="col-sm-4 control-label">原手机号码：</label>
							<div class="col-sm-8">
								<input type="tel" class="form-control" name="telephone" maxlength="11" placeholder="请输入11位手机号码" value="{{ \Request::old('telephone') }}">
								@if ($errors->has('telephone'))
									<span class="error">
                                        {{ $errors->first('telephone') }}
                                    </span>
								@endif
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-4 control-label">短信验证码：</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" name="code" placeholder="请输入短信验证码">
								<a href="#" class="getCode" onclick="javascript:get_securiytCode();">获取验证码</a>
								<div class="reset-code" style="display:none;"><span class="c_second">60</span>S</div>
								@if ($errors->has('code'))
									<span class="error">
                                        {{ $errors->first('code') }}
                                    		</span>
								@endif
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-4 control-label">验证码：</label>
							<div class="col-sm-8">
								<input type="text" class="form-control" name="codeImg" placeholder="请输入验证码">
								<a class="yzm" onclick="javascript:re_captcha();">
									<img src="{{captcha_src()}}" alt="验证码" title="刷新图片" width="100" height="34" id="captcha">
								</a>
							</div>
						</div>
						<div class="form-group">
							<div class="col-sm-12">
								<button type="submit" class="reguesterBtn">下一步</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
@endsection

@section('footer')
	@include('layouts.footer')
@endsection

@section('script')
	<script src="{{ asset('statics/js/jplaceholder.js') }}" ></script>
	<script src="{{ asset('statics/js/from.js') }}" ></script>
	<script>
        function re_captcha() {
            $url = "{{ captcha_src() }}";
            $url = $url + "/" + Math.random();
            document.getElementById('captcha').src=$url;
        }
        function get_securiytCode() {
            var mobile = $('input[name="telephone"]').val();
            if(!mobile){
                alert('手机号码为空的啦');
            }else{
                var url = "{{ route('mobileCode')}}";
                $.ajax({
                    type: "get",
                    url: url,
                    data: {'mobile':mobile},
                    success: function(data) {
                        show_second();
                        console.log(data);
                        alert('发送验证码成功，注意查收！验证码有效期5分钟');
                    },
					error: function (err) {
						alert('发送失败');
					}
                });
            }
        }
        function show_second(){
            $(".getCode").hide();
            $('.c_second').html('60');
            $('.reset-code').show();
            var second = 60;
            var timer = null;
            timer = setInterval(function(){
                second -= 1;
                if(second >0 ){
                    $('.c_second').html(second);
                }else{
                    clearInterval(timer);
                    $('.getCode').show();
                    $('.reset-code').hide();
                }
            },1000);
        }
        //---------------------表单提交--------------------//
        $("form").submit(function(){
            var f=true;//假设通过
            if(checkTel()==false) f=false;
            return f;
        });
	</script>
@stop